The increasing growth of computers and the internet has provided a new and widely used platform for providing network services. This has significantly increased the provision of administrative, social, financial, educational and recreational services on the network, particularly the internet. The expansion of the use of Internet applications creates an opportunity to abuse the network and its information for criminal purposes. Based on this, intrusion into the network and unauthorized access to information have become the main concerns of network users as well as network managers. Intrusion detection systems include a set of tools and mechanisms for monitoring computer systems and network traffic. Various methods are used for intrusion detection, such as statistical techniques, cognitive-based methods, and machine learning methods. In the present research, a method for intrusion detection using machine learning algorithms was reviewed and proposed. The proposed model is a multi-class method that, in addition to intrusion detection, also determines the type of attack. This method is a hybrid model in which the combination of the Seagull optimization algorithm, thermal exchange optimization algorithms and random forest algorithm are used. CICIDS-2017 dataset was used for analysis in this research. The proposed method was compared with several different algorithms and the accuracy value of the proposed method was equal to 98.8, which is higher than that of many machine learning methods.